$(document).ready(function() {
    // 投票按钮点击事件
    $('.vote-btn').click(function() {
        var spotId = $(this).data('id');
        var btn = $(this);

        $.ajax({
            url: '/vote',
            type: 'POST',
            data: { spotId: spotId },
            success: function(response) {
                if (response.success) {
                    alert(response.msg);
                    btn.text('已投票').prop('disabled', true);
                    // 刷新页面更新票数
                    location.reload();
                } else {
                    alert(response.msg);
                }
            },
            error: function() {
                alert('投票失败，请稍后重试');
            }
        });
    });
});